﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class SearchForCoach : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("Default.aspx");
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.SearchForCoach_PageTitle;
            
            OnlineUser ou = (OnlineUser)Session["User"];
            if (ou.TeamId == "Null")
                Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");
            
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string MinVal = this.MinDropDownList.SelectedValue;
            string MaxVal = this.MaxDropDownList.SelectedValue;
            //string Country = this.CountriesDropDownList.SelectedValue;
            string CharismaMin = this.CharismaMinDDL.SelectedValue;
            string CharismaMax = this.CharismaMaxDDL.SelectedValue;
            if (Convert.ToInt16(MinVal) > Convert.ToInt16(MaxVal))
            {
                this.ConfirmMessage.ForeColor = System.Drawing.Color.Red;
                this.ConfirmMessage.Text = Resources.Resource.SearchForCoach_ErrorConfirmMessage;
                MessagePanel.Visible = true;
                //Response.Write(Country);
            }
            else
            {
                this.ShowFreeCoachesSqlDataSource.SelectParameters.Clear();
                this.ConfirmMessage.Text = "";
                MessagePanel.Visible = false;
                this.FreecochesListView.Visible = true;
                if (IsPostBack)
                {
                    this.ShowFreeCoachesSqlDataSource.SelectParameters.Add("MinLevel", MinVal);
                    this.ShowFreeCoachesSqlDataSource.SelectParameters.Add("MaxLevel", MaxVal);
                    //this.ShowFreeCoachesSqlDataSource.SelectParameters.Add("Country", Country);
                    this.ShowFreeCoachesSqlDataSource.SelectParameters.Add("MinCharisma", CharismaMin);
                    this.ShowFreeCoachesSqlDataSource.SelectParameters.Add("MaxCharisma", CharismaMax);
                }

            }

        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }
    }
}